<?php

/* @var $this yii\web\View */
use yii\helpers\Html;
use yii\grid\GridView;
use app\models\ChargeCashDeal;
use yii\data\ActiveDataProvider;

$dataProvider = new ActiveDataProvider([
    'query' => ChargeCashDeal::find()
              ->where([
                'type'=>[3,4],
                'member_id'=>Yii::$app->user->getId()
              ])
              ->orderBy(['reg_dt'=>SORT_DESC])
              ,
    'pagination' => [
        'pageSize' => 20,
    ],
]);

$this->title = '资金互转记录';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="page-title">
  <div>
    <h1><i class="fa fa-users"></i> 资金互转记录</h1>
    <ul class="breadcrumb side">
      <li><i class="fa fa-home fa-lg"></i></li>
      <li>账户管理</li>
      <li class="active"><a href="#">资金互转记录</a></li>
    </ul>
  </div>
</div>
<div class='card'>
<?php
//如何提前加载资源
echo GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
  'class' => 'yii\grid\SerialColumn',
  'header'=>'序号'
],
// 数据提供者中所含数据所定义的简单的列
// 使用的是模型的列的数据
'reg_dt',
[
  'header'=>'转账类型',
  'content'=>function ($model, $key, $index, $column) {
    if($model->type==ChargeCashDeal::TYPE_USD_NEA){
      return '个人账户转基金账户';
    }else if($model->type==ChargeCashDeal::TYPE_NEA_USD){
      return '基金账户转个人账户';
    }else{
      return '非法转帐类型';
    }
  },
],
[
  'header'=>'转账金额',
  'content'=>function ($model, $key, $index, $column) {
      return number_format($model->money,2);
  },
],
[
  'header'=>'状态',
  'content'=>function ($model, $key, $index, $column) {
    switch($model->status){
      case ChargeCashDeal::STATUS_REGISTER:
      return '<i class="fa fa-hourglass-half"></i> 正在审核';
      case ChargeCashDeal::STATUS_PROVED:
      return '<i class="fa fa-check-circle alert-info"></i> 成功';
      case ChargeCashDeal::STATUS_UNPROVED:
      return '<i class="fa fa-times-circle alert-danger"></i> 失败';
      case ChargeCashDeal::STATUS_DISCARD:
      return '<i class="fa fa-trash alert-default"></i> 作废';
      default:
      return '<i class="fa fa-trash alert-default"></i> 作废';
    }
  },
],

],

]);
?>
</div>
